﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true"
    CodeBehind="customers_new.aspx.cs" Inherits="LinkCard.AdminCP.CRM.customers_new" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        var $j = jQuery.noConflict(); //set no conflict so you can use with MS AJAX.
        var submitUsername = true;
        var submitPassword = true;
        var submitConfirmPw = true;

        $j(document).ready(function () {
            //Set first 2 number of card reader by city
            //Gen Key
            $j("#<%=Birthday.ClientID %>").datepicker();
            $j("#<%=ExpiredDate.ClientID %>").datepicker();
            //Thay doi => tu dong gen key
            $j("#<%=CardType.ClientID %>").change(TaoMaThe).trigger('change');
            $j("#<%=city.ClientID %>").change(TaoMaThe).trigger('change');



            //only number
            $j("#<%=CardNumber.ClientID %>").keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                    // Allow: Ctrl+A
                    (event.keyCode == 65 && event.ctrlKey === true) ||
                    // Allow: home, end, left, right
                    (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything

                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();

                    }
                }

            });

          

            $j("#<%=btnPublish.ClientID %>").click(function () {
                
                if ($j("#<%=CardNumber.ClientID %>").val().length < 16) {
                    $j("#spanCardNumber").css({
                        "color": "red", "font-weight": "bold", "font-size": "small",
                        "padding-left": "15px"
                    });

                    $j("#spanCardNumber").text("Mã thẻ chưa đủ 16 kí tự")
                    return false;
                }

                if (submitUsername == true && submitPassword == true && submitConfirmPw == true && submitCardNumber == true) {
                    return true;
                }
                else {
                    return false;
                }
                return false;
            });

            //Check ma the ko trung
            $j("#<%=CardNumber.ClientID %>").blur(CheckMaThe);
        });

        function TaoMaThe() {
            var cityText = "";
            var cardType = "";
            var shopText = "";

            var curDate = new Date();
            var curYear = curDate.getFullYear();
            curYear = curYear.toString().slice(2);

         

            $j("select[id$='city'] option:selected").each(function () {
                cityText += $j(this).val();
            });

            $j("select[id$='CardType'] option:selected").each(function () {
                cardType += $j(this).val();
            });

            var numLow = 100000000000;
            var numHigh = 999999999999;

            var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1;

            var numRand = Math.floor(Math.random() * adjustedHigh) + parseFloat(numLow);

            $j("#<%=CardNumber.ClientID %>").val(cardType + cityText + curYear + numRand);

            CheckMaThe();
        }

        function CheckMaThe() {
            $j.ajax({
                type: "POST",
                url: "customers_new.aspx/CheckCardNumber",
                data: "{'sCardNumber':'" + $j("#<%=CardNumber.ClientID %>").val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (message) {
                    //Set the spanChecking text letting user know if the uname is available
                    if (message.d != true) {
                        $j("#spanCardNumber").css({
                            "color": "red", "font-weight": "bold", "font-size": "small",
                            "padding-left": "15px"
                        });

                        $j("#spanCardNumber").text("Mã thẻ đã tồn tại")
                        submitCardNumber = false;
                    }
                    else {
                        $j("#spanCardNumber").css({
                            "color": "green", "font-weight": "bold", "font-size": "small",
                            "padding-left": "15px"
                        });
                        $j("#spanCardNumber").text("Mã thẻ có thể sử dụng")
                        submitCardNumber = true;
                    }
                },
                error: function (errormessage) {
                    //you would not show the real error to the user - this is just to see if everything is working
                    $j("#spanChecking").text(errormessage.responseText);
                }
            });
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <section id="content">
        <section class="container_12 clearfix">
            <section id="main" class="grid_12">
                <article>
                    <div class="h1">Thêm mới khách hàng</div>

                    <dl class="inline">
                        <dt></dt>
                        <dd>
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server"
                                HeaderText="* Thông tin bắt buộc:" ForeColor="Red" CssClass="Validator" />
                        </dd>
                       <%-- <dt>
                            <label>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                                    ControlToValidate="Username"
                                    ErrorMessage="Tên đăng nhập." ForeColor="Red"> *
                                </asp:RequiredFieldValidator>
                                Tên đăng nhập:</label>
                        </dt>
                        <dd>
                            <input type="text" class="medium" id="Username" runat="server" />
                            <span id="spanUsername"></span>
                            <span id="output"></span>
                        </dd>--%>
                       
                        <dt>
                            <label>Họ và tên:</label>
                        </dt>
                        <dd>
                            <input type="text" class="big" id="Fullname" runat="server" />
                        </dd>
                        <dt>
                            <label>Hạng thẻ:</label>
                        </dt>
                        <dd>
                            <select id="CardLevel" runat="server" class="medium required">
                                <option value='1'>Gold</option>
                            </select>
                        </dd>
                        <dt>
                            <label>Loại thẻ:</label>
                        </dt>
                        <dd>
                            <select id="CardType" runat="server" class="medium required">
                                <option value='1'>Thẻ thường</option>
                                <option value='2'>Thẻ liên kết</option>
                                <option value='8'>Thẻ VIP</option>
                                <option value='9'>Thẻ ngân hàng</option>
                            </select>
                        </dd>
                        <dt>
                            <label>Tỉnh / thành phố:</label>
                        </dt>
                        <dd>
                            <select id="city" runat="server" class="medium required">
                                <option value="" selected>Vui lòng chọn...</option>
                                <option value='8'>Hồ Ch&iacute; Minh</option>
                                <option value='9'>H&agrave; Nội</option>
                                <option value='6'>Miền Trung</option>
                                <option value='0'>Khác</option>
                            </select>
                        </dd>
                     <%--   <dt>
                            <label>Đối tác - Shop:</label>
                        </dt>
                        <dd>
                            <select id="ddlShop" runat="server" class="medium required">
                                <option value="" selected>Vui lòng chọn...</option>
                            </select>
                        </dd>--%>
                        <%--   <dt>
              <label ></label>
            </dt>
            <dd>
                <input type="button" id="GenKey" class="button white" value="Tạo mã thẻ"/>
                
            </dd>--%>
                        <dt>
                            <label><strong>Số thẻ (tên đăng nhập) *:</strong></label>
                        </dt>
                        <dd>
                            <input type="text" class="small" id="CardNumber" runat="server" maxlength="16" />
                            <span id="spanCardNumber"></span>
                        </dd>
                         <dt>
                            <label>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                                    ControlToValidate="Password"
                                    ErrorMessage="Mật khẩu" ForeColor="Red"> *
                                </asp:RequiredFieldValidator>Mật khẩu *:</label>
                        </dt>
                        <dd>
                            <input type="text" id="Password" class="medium required" runat="server" />
                         <%--   <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" Display="Dynamic"
                                ControlToValidate="Password"
                                ErrorMessage="Mật khẩu cần có một trong các ký tự @#$%^&*/." ForeColor="Red"
                                ValidationExpression=".*[@#$%^&*/].*" />--%>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" Display="Dynamic"
                                ControlToValidate="Password"
                                ErrorMessage="Mật khẩu từ 4 đến 12 ký tự." ForeColor="Red"
                                ValidationExpression="[^\s]{4,12}" />
                        </dd>
                        <dt>
                            <label>Ngày hết hạn:</label>
                        </dt>
                        <dd>
                            <input type="text" id="ExpiredDate" runat="server" readonly />
                            <asp:CheckBox ID="ckNoExpiredDate" runat="server" /> Không giới hạn
                        </dd>
                        <dt>
                            <label>Số thẻ GLP:</label>
                        </dt>
                        <dd>
                            <input type="text" class="small" id="VietnamAirlineGLPNumber" runat="server" />
                        </dd>
                        <%-- <dt>
              <label >Số điểm tích lũy:</label>
            </dt>
            <dd>
              <input type="text" class="big" id="Point" runat="server" readonly value="0" />
            </dd>--%>
                        <dt>
                            <label>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                                    ControlToValidate="Birthday"
                                    ErrorMessage="Ngày sinh." ForeColor="Red"> *
                                </asp:RequiredFieldValidator>Ngày sinh:</label>
                        </dt>
                        <dd>
                            <input type="text" id="Birthday" runat="server" />
                        </dd>
                        <dt>
                            <label>Số CMTND:</label>
                        </dt>
                        <dd>
                            <input type="text" class="big" id="ID" runat="server" />
                        </dd>
                        <dt>
                            <label>Giới tính:</label>
                        </dt>
                        <dd>
                            <asp:RadioButtonList ID="Gender" runat="server" RepeatColumns="3">
                                <asp:ListItem Text="Nam" Value="0" Selected="True"></asp:ListItem>
                                <asp:ListItem Text="Nữ" Value="1"></asp:ListItem>
                                <asp:ListItem Text="Khác" Value="2"></asp:ListItem>
                            </asp:RadioButtonList>
                        </dd>
                        <dt>
                            <label>Điện thoại di động:</label>
                        </dt>
                        <dd>
                            <input type="text" class="big" id="MobilePhone" runat="server" />
                        </dd>
                        <dt>
                            <label>Email:</label>
                        </dt>
                        <dd>
                            <input type="text" class="big" id="Email" runat="server" />
                        </dd>
                        <dt>
                            <label>Địa chỉ:</label>
                        </dt>
                        <dd>
                            <textarea class="big" rows="4" id="Address" runat="server"></textarea>
                        </dd>
                        <dt>
                            <label>Nghề nghiệp:</label>
                        </dt>
                        <dd>
                            <input type="text" class="big" id="Job" runat="server" />
                        </dd>
                        <dt>
                            <label>Thu nhập:</label>
                        </dt>
                        <dd>
                            <input type="text" class="big" id="Income" runat="server" />
                        </dd>
                        <dt>
                            <label>Thông tin khác:</label>
                        </dt>
                        <dd>
                            <textarea class="big" rows="4" id="OtherInfo" runat="server"></textarea>
                        </dd>
                      <%--  <dt>
                            <label>Tags:</label>
                        </dt>
                        <dd>
                            <input type="text" class="medium" id="txtTags" runat="server" />
                        </dd>--%>
                        <%-- <dt>
              <label >Số tiền đã giao dịch:</label>
            </dt>
            <dd>
              <input type="text"   class="big" id="TransactionAmount"  runat="server" readonly value="0" />
            </dd>--%>
                        <dt>
                            <label>Hệ thống đăng ký:</label>
                        </dt>
                        <dd>

                            <asp:RadioButtonList ID="SystemRegister" runat="server" RepeatColumns="3">
                                <asp:ListItem Text="Online" Value="0"></asp:ListItem>
                                <asp:ListItem Text="Qua cửa hàng" Value="1"></asp:ListItem>
                                <asp:ListItem Text="Trực tiếp từ TopLink" Value="2" Selected="True"></asp:ListItem>
                            </asp:RadioButtonList>
                        </dd>
                    </dl>
                    <p>
                        <asp:Button class="button big" Text="Chuyển duyệt" ID="btnPublish" runat="server"
                            OnClick="btnPublish_Click" Style="width: auto;" />
                        <%--<asp:Button class="button white" Text="Lưu tạm" ID="btnAdd" runat="server"
                            OnClick="btnAdd_Click" />--%>
                    </p>

                </article>
            </section>
        </section>
    </section>
</asp:Content>
